<!-- <template>
	<uni-section title="记录查询" subTitle="使用身份证号+姓名+人员类型" type="line" padding>
		<uni-forms ref="baseForm" :modelValue="baseFormData">
			<uni-forms-item label="身份证号">
				<uni-easyinput v-model="baseFormData.idNumber" placeholder="身份证号" />
			</uni-forms-item>
			<uni-forms-item label="姓名">
				<uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" />
			</uni-forms-item>
			<uni-forms-item label="人员类型">
				<uni-data-select v-model="baseFormData.type" :localdata="range"> </uni-data-select>
			</uni-forms-item>
			<button type="primary" @click="search">查询</button>
		</uni-forms>
		<uni-section title="查询结果" type="line">
			<uni-list v-for="item in logList" v-if="logList&&logList.length>0">
				<uni-list-item :title="item.name" :rightText="item.examineTime" showArrow clickable
					@click="look(item)" />
			</uni-list>
			<text v-else style="margin-left: 40%;font-size: 12px;color: rgb(153, 153, 153);">暂无数据</text>
		</uni-section>
	</uni-section>

</template>

<script>
	import {
		request
	} from '../../api/request.js';
	export default {
		data() {
			return {
				// 基础表单数据
				baseFormData: {
					name: '',
					idNumber: "",
					type: null,
				},
				range: [{
						value: 1,
						text: "用户"
					},
					{
						value: 2,
						text: "访客"
					},
				],
				logList: []
			}
		},

		methods: {
			search() {
				request({
					url: "/api/v1/people-info/search",
					method: "GET",
					data: this.baseFormData
				}).then(res => {
					this.logList = res.data;
				})

			},
			look(item) {
				uni.navigateTo({
					url: "/pages/detail/index?item=" + JSON.stringify(item)
				})
			}
		}
	}
</script>


<style lang="scss">
	.example {
		padding: 15px;
		background-color: #fff;
	}

	.segmented-control {
		margin-bottom: 15px;
	}

	.button-group {
		margin-top: 15px;
		display: flex;
		justify-content: space-around;
	}

	.form-item {
		display: flex;
		align-items: center;
	}

	.button {
		display: flex;
		align-items: center;
		height: 35px;
		margin-left: 10px;
	}
</style> -->

<template>
	<view>
		<!-- <button >登录授权并获取信息</button> -->
		<div>
			<div class="cicle" style="width: 50px;height: 50px;border-radius: 50%;background-color: aliceblue;"></div>
			<text @click="getUserInfo">登录</text>
		</div>
		<uni-list>
			<uni-list-item title="个人中心" clickable showArrow @click="goUserInfo"></uni-list-item>

			<uni-list-item title="我的申请" clickable showArrow @click="onClick"></uni-list-item>
			<uni-list-item title="我的审核" clickable showArrow @click="onClick"></uni-list-item>

		</uni-list>
	</view>
</template>
<script>
	import {
		request
	} from '../../api/request';
	export default {
		data() {
			return {
				info: {}
			}
		},
		onLoad() {
			let openid = wx.getStorageSync('openId')
			request({
				url: `/api/v1/people-info/openid?openid=${openid}`,
				method: 'GET'
			}).then(res => {
				console.log(res);
				this.info = res.data;
			})
		},
		methods: {
			goUserInfo() {
				uni.navigateTo({
					url: "/pages/detail/index?item=" + JSON.stringify(this.info)
				})
			},
			// 触发登录授权并获取用户信息
			getUserInfo() {
				uni.getUserProfile({
					desc: '用于完善会员资料', // 必填，声明获取用户个人信息后的用途
					success: (res) => {
						console.log('用户信息：', res.userInfo);
						// 获取用户昵称和头像
						const {
							nickName,
							avatarUrl
						} = res.userInfo;
						// 进一步处理用户昵称和头像
						this.handleUserInfo(nickName, avatarUrl);
					},
					fail: (err) => {
						console.log('用户信息获取失败：', err);
					}
				});
			},
			// 处理用户信息
			handleUserInfo(nickName, avatarUrl) {
				// 这里可以将昵称和头像保存到本地或发送到服务器
				console.log('昵称：', nickName);
				console.log('头像：', avatarUrl);
			}
		}
	}
</script>